<?php
namespace Pinenut\Form;

class RenderAction extends \Pinenut\Action
{
	public function run()
	{
		$params = $this->request->params();
		$htmlOptions = '';
		if (!empty($params['htmlOptions'])) {
			foreach($params['htmlOptions'] as $name => $value) {
				if ('class' == $name) {
					continue;
				}
				$htmlOptions .= ' ' . $name . '="' . $value . '"';
			}
		}

		$elementValue = '';
		if (!empty($params['value'])) {
			$elementValue = $params['value'];
		}

		$this->response->value = $elementValue;
		$this->response->params = $params;
		$this->response->htmlOptions = $htmlOptions;
		$this->response->elementClass = !empty($params['htmlOptions']['class']) ? $params['htmlOptions']['class'] : null;
	}
}